package am.NotenProgramm.objects;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class myDate {

	int day = 1;
	int month = 1;
	int year = 2013;

	public myDate(int day, int month, int year) {
		this.day = day;
		this.month = month;
		this.year = year;
	}
	
	public myDate(String date) {
		String[] splitedElements = date.split("\\.");
		if(splitedElements.length == 3) {
			this.day = Integer.parseInt(splitedElements[0]);
			this.month = Integer.parseInt(splitedElements[1]);
			this.year = Integer.parseInt(splitedElements[2]);
		} else {
			System.out.println("Wrong dateformat!");
		}
	}
	
	public myDate() {
		Calendar cal = Calendar.getInstance();
		DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
		String[] splitedElements = dateFormat.format(cal.getTime()).toString().split("\\.");
		this.day = Integer.parseInt(splitedElements[0]);
		this.month = Integer.parseInt(splitedElements[1]);
		this.year = Integer.parseInt(splitedElements[2]);
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	public int getYear() {
		return year;
	}

	public void setYear(int year) {
		this.year = year;
	}
}
